package com.hs.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hs.sfzy.entity.UserMark;
import com.hs.sfzy.mapper.UserMarkMapper;
import com.hs.sfzy.service.UserMarkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;

/**
 * @ClassName UserMarkServiceImpl
 * @Description TODO
 * @Author QinKunPeng
 * @Date 2024年10月25日 15:57
 * @Version 1.0
 */
@Service
@Transactional
public class UserMarkServiceImpl implements UserMarkService {

    @Autowired
    UserMarkMapper userMarkMapper;

    /**
     * 根据id删除用户评论
     * @author QinKunPeng
     * @date 2024/10/25 15:57
     * @param id
     * @return int
     */
    @Override
    public int deleteUserMark(long id) {
        return userMarkMapper.deleteUserMark(id);
    }

    /**
     * 添加用户评论【小程序端】
     * @author QinKunPeng
     * @date 2024/10/25 15:58
     * @param userMark
     * @return int
     */
    @Override
    public int addUserMark(UserMark userMark) {
        return userMarkMapper.addUserMark(userMark);
    }

    /**
     * 动态条件查询用户评价
     * @author QinKunPeng
     * @date 2024/10/25 15:59
     * @param userMark
     * @return java.util.List<com.hs.sfzy.entity.UserMark>
     */
    @Override
    public List<UserMark> getUserMarkList(UserMark userMark) {
        return userMarkMapper.getUserMarkList(userMark);
    }

    /**
     * 分页，动态条件查询用户评价
     * @author QinKunPeng
     * @date 2024/10/25 15:59
     * @param userMark
     * @param pageNum
     * @param pageSize
     * @return com.github.pagehelper.PageInfo<com.hs.sfzy.entity.UserMark>
     */
    @Override
    public PageInfo<UserMark> getUserMarkListByPage(UserMark userMark, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<UserMark> list = userMarkMapper.getUserMarkList(userMark);
        PageInfo<UserMark> pageInfo = new PageInfo<UserMark>(list);
        return pageInfo;
    }

    /**
     * 根据id查询用户评价【小程序】
     * @author QinKunPeng
     * @date 2024/10/25 16:00
     * @param id
     * @return com.hs.sfzy.entity.UserMark
     */
    @Override
    public UserMark getUserMarkById(long id) {
        return userMarkMapper.getUserMarkById(id);
    }

    /**
     * 根据外键【咨询预约id】删除用户评价
     * 【删除咨询预约需要使用】
     * @author QinKunPeng
     * @date 2024/10/25 16:01
     * @param id
     * @return int
     */
    @Override
    public int deleteByAppId(long id) {
        return userMarkMapper.deleteByAppId(id);
    }
}
